package com.example.lvsuo.service.impl;

import com.example.lvsuo.entity.HrEmp;
import com.example.lvsuo.entity.vo.RecordArchiveslibraryVo;
import com.example.lvsuo.service.IRecordArchiveslibraryService;
import com.example.lvsuo.entity.RecordArchiveslibrary;
import com.example.lvsuo.mapper.RecordArchiveslibraryMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 档案/档案借阅 服务实现类
 * </p>
 *
 * @author 心心念念
 * @since 2021-03-30
 */
@Service
public class RecordArchiveslibraryServiceImpl extends ServiceImpl<RecordArchiveslibraryMapper, RecordArchiveslibrary> implements IRecordArchiveslibraryService {
    @Autowired
    RecordArchiveslibraryMapper recordArchiveslibraryMapper;

    /**
     * 高级查询+分页
     * @param recordArchiveslibraryVo
     * @return
     */
    @Override
    public List<RecordArchiveslibraryVo> getRecordArchiveslibrary(RecordArchiveslibraryVo recordArchiveslibraryVo) {
        return recordArchiveslibraryMapper.getRecordArchiveslibrary(recordArchiveslibraryVo);
    }

    /**
     * 删除
     * @param id
     */
    @Override
    public void deleteRecordArchiveslibrary(String id) {
        //根据id查当前员工状态
        List<RecordArchiveslibrary> borrowStatus = recordArchiveslibraryMapper.getBorrowStatusId(id);
        for (RecordArchiveslibrary ra: borrowStatus){
            //判断在职状态是否可以删除
            if(ra.getBorrowStatus().equals("Y")){
                //删除查询的状态=‘Y’的id
                recordArchiveslibraryMapper.deleteRecordArchiveslibrary(ra.getId().toString());
            }
        }
    }

    /**
     *添加
     * @param recordArchiveslibrary
     */
    @Override
    public void insertRecordArchiveslibrary(RecordArchiveslibrary recordArchiveslibrary) {
     recordArchiveslibraryMapper. insertRecordArchiveslibrary(recordArchiveslibrary);
    }

    /**
     * 根据ID查询
     * @param id
     * @return
     */
    @Override
    public List<RecordArchiveslibraryVo> getRecordArchiveslibraryId(String id) {
        return recordArchiveslibraryMapper.getRecordArchiveslibraryId(id);
    }

}
